package com.itawei.TCPpractise.num1;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

/**
 * 客户端：多次发送数据
 * 服务器：接收多次接收数据 并打印
 */
public class Client {
    public static void main(String[] args) throws IOException {
        //1.创建一个Socket对象 发送的地址
        Socket socket = new Socket("127.0.0.1", 10086);
        Scanner sc = new Scanner(System.in);
        //2.获取输出流
        OutputStream os = socket.getOutputStream();
        while (true) {
            System.out.println("请输入要发送的信息：");
            String s = sc.next();
            if("886".equals( s)){
                break;
            }
            byte[] bytes = s.getBytes();
            os.write(bytes);
        }
        //3.释放资源
        os.close();


    }
}
